package com.ruoyi.web.controller.material;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.IcSapplyH;
import com.ruoyi.system.domain.MarterialVo;
import com.ruoyi.system.domain.PoStorereq;
import com.ruoyi.system.domain.RequestPurchase;
import com.ruoyi.system.domain.vo.MRequestVo;
import com.ruoyi.system.service.IIcSapplyHService;
import com.ruoyi.system.service.IPoStorereqService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2024-01-06
 */
@Api(tags = "采购申请记录")
@RestController
@RequestMapping("/poStorereq")
public class PoStorereqController extends BaseController
{
    @Autowired
    private IPoStorereqService iPoStorereqService;

    /**
     * 查询【请填写功能名称】列表
     */
    @ApiOperation("查看采购申请记录列表")
    @GetMapping("/list")
    public TableDataInfo list(PoStorereq icSapplyH)
    {
        startPage();
        List<PoStorereq> list = iPoStorereqService.selectPoStorereqList(icSapplyH);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @ApiOperation("导出采购申请记录列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, PoStorereq poStorereq)
    {
        List<PoStorereq> list = iPoStorereqService.selectPoStorereqList(poStorereq);
        ExcelUtil<PoStorereq> util = new ExcelUtil<PoStorereq>(PoStorereq.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }


    @ApiOperation("领用引用采购的列表信息")
    @PostMapping("/getAllPostorereq")
    public AjaxResult  getAllPostorereq(@RequestBody MRequestVo map){
        List<MarterialVo>  requestPurchase = iPoStorereqService.getAllPostorereq(map.getPid());
        return AjaxResult.success(requestPurchase);
    }

    @ApiOperation("查看采购申请编号列表")
    @GetMapping("/getListId")
    public AjaxResult getListId()
    {
        List<String> list = iPoStorereqService.getListId();
        return AjaxResult.success(list);
    }
}
